package com.jorigin.socketServer;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author lizq
 */
public class DoMainSocketServerImpl {
    
    public static String processRequest(String req){
        return req ;
    }
    
    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(8080);){
            
            Socket clientSocket = serverSocket.accept();
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
    
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true);
            String request ,response ;
            while ((request = in.readLine())!=null){
                if("Done".equals(request)){
                    break;
                }
                response = processRequest(request);
                out.println(response);
            }
            
        }catch (Exception e){
            e.printStackTrace();
        }finally {
        }
       
        
    }
}
